<?php

namespace Acme\StoreBundle\Helper;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class BaseSitesController extends Controller {
    protected $subDomain;
    
    public function __construct() {
//        $host = $_SERVER['SERVER_NAME'];
//        $baseHosts = $this->container->getParameter('base_host');
//        $subDomain = str_replace('.'. $baseHosts, '', $host);
//        
//        ini_set('error_reportings', 1);
//       
//        $view = "StoreBundle:Sites\ ".  $subDomain. '_:index.html.twig';
//        $view = str_replace(' ', '', $view);
        
    }
    
    public function getSubDomain() {
        
        $host = $this->getRequest()->getHost();
        $baseHosts = $this->container->getParameter('base_host');
        $this->subDomain = str_replace('.'. $baseHosts, '', $host);
        return $this->subDomain;
    }
    
    public function getView($view) {
        
        $view = "StoreBundle:Sites\ ".  $this->getSubDomain(). '_:'.$view.'.html.twig';
        return str_replace(' ', '', $view);
        
    }
    
}